package com.kumi.blog.article.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kumi.common.utils.PageUtils;
import com.kumi.common.utils.Query;

import com.kumi.blog.article.mapper.CategoryreferencedMapper;
import com.kumi.blog.article.bean.Categoryreferenced;
import com.kumi.blog.article.service.CategoryreferencedService;
import org.springframework.util.StringUtils;


@Service("categoryreferencedService")
public class CategoryreferencedServiceImpl extends ServiceImpl<CategoryreferencedMapper, Categoryreferenced> implements CategoryreferencedService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<Categoryreferenced> wrapper = new QueryWrapper<>();
        String key = (String) params.get("key");
        if (!StringUtils.isEmpty(key)){
            wrapper.eq("cr_id",key).or().eq("cr_articleid",key);
        }
        IPage<Categoryreferenced> page = this.page(
                new Query<Categoryreferenced>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

}